package connect

import "project/models"

func GetAllUsers(usersParam map[string]interface{}) (error, []models.Users, int64) {
	var usersData []models.Users
	page := usersParam["page"].(int)
	pageSize := usersParam["limit"].(int)
	searchName := usersParam["searchName"].(string)
	var total int64
	err := db.Table("users").Where("username like ? ", "%"+searchName+"%").Order("username ASC").Count(&total).Offset((page - 1) * pageSize).Limit(pageSize).Find(&usersData).Error
	return err, usersData, total
}
